﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    public static class Vector4Extensions
    {
        public static Vector4 Parse(string text)
        {
            Vector4 result;
            if (!TryParse(text, out result))
            {
                string message = string.Format("The string {0} can not convert to Rect.", text);
                throw new FormatException(message);
            }
            return result;
        }
        public static bool TryParse(string text, out Vector4 v)
        {
            if (text.Length < 2 || text[0] != '(' || text[text.Length - 1] != ')')
            {
                v = Vector4.zero;
                return false;
            }
            string[] array = text.Substring(1, text.Length - 2).Split(new char[]
            {
                ','
            });
            if (array.Length != 4)
            {
                v = Vector4.zero;
                return false;
            }
            float num = float.Parse(array[0]);
            float num2 = float.Parse(array[1]);
            float num3 = float.Parse(array[2]);
            float num4 = float.Parse(array[3]);
            v = new Vector4(num, num2, num3, num4);
            return true;
        }
    }
}

